﻿using Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using 后整理管理系统.自定义类;
using 纺织贸易管理系统;
using 纺织贸易管理系统.设置窗体;

namespace 后整理管理系统.选择窗体
{
    public partial class 入库单选择 : Form
    {
        public List<danjumingxitable> resMingxiList = new List<danjumingxitable>();
        public 入库单选择()
        {
            InitializeComponent();
            CreateGrid.Create(this.Name, gridView1);
            dateTimePicker2.Value = DateTime.Now;
            dateTimePicker1.Value = dateTimePicker2.Value.AddDays(-10);
        }
        private void Query()
        {
            string sql = $"select * from danjumingxitable where danhao in (select danhao from danjumingxitable where ganghao like '%{txtganghao.Text }%')" +
                $" and CustomName like '%{txtkehu.Text }%' and pingming like '%{txtpingming.Text }%' and danhao like 'SC%' and rq between '{dateTimePicker1.Value.Date}' and '{dateTimePicker2.Value.Date.AddDays(1)}'";

            gridControl1.DataSource = danjumingxitableService.Getdanjumingxitablelst(sql); 
        }

        private void uiSymbolButton1_Click(object sender, EventArgs e)
        {
            Query();
        }

        private void txtpingming_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.KeyCode==Keys.Enter )
            {
                Query();
            }
        }

        private void 配置列ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var fm = new 配置列(gridView1) { formname = this.Name, Obj = new danjumingxitable () };
            fm.ShowDialog();
        }

        private void 保存样式ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CreateGrid.SaveGridview(this.Name, gridView1);
        }

        private void 入库单选择_FormClosed(object sender, FormClosedEventArgs e)
        {
            resMingxiList = SelectHelper.GetSelectList<danjumingxitable>(gridView1);
            this.Close(); 
        }

        private void uiSymbolButton2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void gridView1_DoubleClick(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
